package com.example.chapter5.controller;

import com.example.chapter5.entity.Student;
import com.example.chapter5.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentController {
    @Autowired
    private StudentMapper studentMapper;

    @GetMapping(value = "/students/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public Student student(@PathVariable("id") int id) {
        return studentMapper.findStudentById(id);
    }
}
